import React from 'react'
import { renderToNodeStream } from 'react-dom/server'
import { StaticRouter } from 'react-router-dom'
import { createStore, applyMiddleware, compose } from 'redux'
import thunk from 'redux-thunk'
import { Provider } from 'react-redux'
import App from '../src/app'
import reducers from '../src/reducer'


const store = createStore(reducers, compose(
  applyMiddleware(thunk)
))
let context = {}

export default function(req) {
  return renderToNodeStream(
    (<Provider store={store}>
      <StaticRouter
        location={req.url}
        context={context}
      >
        <App></App>
      </StaticRouter>
    </Provider>)
  )
}